import http from '@/utils/request'
import type { PaginationCommon, PaginationRes, PaymentTemplate } from '../common'
import type { ClinicIndex } from './base'
/**排班(请求) */
export interface GetRegisterSchedulePaginationReq extends PaginationCommon {
  queryText: string
  beginDate?: string
}

/**列头 */
export interface RegisterScheduleHeader {
  clinicDate: Date
  title: string
  prop: string
}

/**排班天 */
export interface RegisterScheduleDayRes {
  clinicDate: Date
  timeDesc: string
  workId: string
  registerLimit: number
  registerNum: number
  appointLimit: number
  appointNum: number
  money: number
  pool: boolean
}

/**号源 */
export interface RegisterScheduleDayItemRes extends RegisterScheduleDayRes {
  limitNum: number
  remainNum: number
  doctorName: string
  deptName: string
  clinicType: string
  clinicLabel: string
}

/**排班(响应) */
export interface RegisterScheduleRes extends ClinicIndex {
  days: RegisterScheduleDayRes[]
}

/**排班分页(响应) */
export interface GetRegisterSchedulePaginationRes {
  headers: RegisterScheduleHeader[]
  pagination: PaginationRes<RegisterScheduleRes>
}

export interface GetScheduleDayItemsReq {
  visitDate: string
}

/**挂号支付确认(请求) */
export interface RegisterConfirmPayReq {
  patientId: string
  name: string
  sex?: string
  idNo?: string
  age?: number
  birthday?: Date
  tel?: string
  addr?: string
  chargeType?: string
}

export interface GetRegisterPayRecByPaginationReq extends PaginationCommon {
  inputText: string
  dateType: string
  beginDate: string
  endDate: string
}

/**挂号支付记录(响应) */
export interface RegisterPayRecRes {
  clinicNo: string
  patientId: string
  name?: string
  sex?: string
  idNo?: string
  age?: number
  birthday?: Date
  tel?: string
  addr?: string
  status?: number
  chargeType?: string
  clinicCharge?: number
  registFee?: number
  clinicFee?: number
  otherFee?: number
  payDate?: Date
  refundDate?: Date
  payOperatorNo?: string
  payOperatorName?: string
  refundOperatorNo?: string
  refundOperatorName?: string
  deptCode?: string
  deptName?: string
  doctorId?: string
  doctorName?: string
  clinicType: string
  visitDate?: Date
  timeDesc?: string
  clinicLabel?: string
  payments: PaymentTemplate[]
}
/**挂号业务数据API */
export const RegisterBusAPIs = {
  /**排班(分页) */
  getSchedule: (data: GetRegisterSchedulePaginationReq) => {
    return http.post<GetRegisterSchedulePaginationRes>('/register/getSchedule', data)
  },
  /**排班(按天) */
  getScheduleDay: (clinicLabel: string, clinicDate: Date) => {
    return http.get<RegisterScheduleRes>('/register/getScheduleDay', {
      clinicDate,
      clinicLabel,
    })
  },
  /**排班(按天) */
  getScheduleDayItems: (data: GetScheduleDayItemsReq) => {
    return http.post<RegisterScheduleDayItemRes[]>('/register/getScheduleDayItems', data)
  },

  /**获取挂号支付记录(分页) */
  getRegisterRec: (data: GetRegisterPayRecByPaginationReq) => {
    return http.post<PaginationRes<RegisterPayRecRes>>('/register/getRegisterRec', data)
  },
  /**获取挂号支付记录 */
  getRegisterRecByClinicNo: (clinicNo: string) => {
    return http.get<RegisterPayRecRes>('/register/getRegisterRecByClinicNo', { clinicNo })
  },
}
